package com.bluesky.plum.uimodels.render.swing.components;

import java.util.Date;

import com.bluesky.plum.richdomain.RichDomainField;
import com.imagine.component.calendar.CalendarComboBox;
import com.imagine.component.calendar.CalendarComponent;
import com.imagine.component.calendar.renderers.CalendarRendererProviderRoundRect;
import com.imagine.component.calendar.skins.styles.CalendarSkinStyleAqua;

public class SDateTimePicker extends
		com.bluesky.plum.uimodels.standard.components.DateTimePicker {

	// JTextField textField;
	CalendarComboBox calendarComboBox;

	public SDateTimePicker(RichDomainField field) {
		super(field);

		calendarComboBox = new CalendarComboBox();

		CalendarComponent calendarComponent = calendarComboBox
				.getCalendarComponent();
		calendarComponent.setCalendarProperty(
				CalendarComponent.FIRST_DAY_OF_WEEK, new Integer(
						java.util.Calendar.MONDAY));
		calendarComponent.getCalendarSkin().applyCalendarSkinStyle(
				new CalendarSkinStyleAqua());
		calendarComponent
				.setCalendarRendererProvider(new CalendarRendererProviderRoundRect());

		calendarComponent.setDate((Date)field.value);
	}

	@Override
	public Object getNativeComponent() {

		return calendarComboBox;

	}

	@Override
	public Date getDatetime() {

		return calendarComboBox.getDate();
	}

	@Override
	public void setDatetime(Date datetime) {
		super.setDatetime(datetime);
		
		calendarComboBox.setDate(datetime);

	}
}
